CFLAGS = -march=pentium2
L10N = de-DE en-US es-ES gl-ES ko-KR ru-RU

all: localization
	makensis /V2 installer.nsi

release: CFLAGS += -O2 -s
release: AltDrag.exe hooks.dll build/ini.exe

debug: CFLAGS += -ggdb3 -DDEBUG
debug: AltDrag.exe hooks.dll

localization: release
	localization.bat $(L10N)

AltDrag.exe: altdrag.c localization/strings.h build/altdrag.o 
	gcc -o AltDrag.exe altdrag.c build/altdrag.o -mwindows -lshlwapi -lwininet $(CFLAGS)

hooks.dll: hooks.c build/hooks.o
	gcc -o hooks.dll hooks.c build/hooks.o include/libcomctl32.a -mdll -lshlwapi -lcomctl32 $(CFLAGS)

build/unhook.exe: include/unhook.c
	@if not exist build. mkdir build
	gcc -o build/unhook.exe include/unhook.c $(CFLAGS)

build/altdrag.o: include/altdrag.rc
	@if not exist build. mkdir build
	windres -o build/altdrag.o include/altdrag.rc

build/hooks.o: include/hooks.rc
	@if not exist build. mkdir build
	windres -o build/hooks.o include/hooks.rc

build/ini.exe:
	@if not exist build. mkdir build
	gcc -o build/ini.exe include/ini.c -lshlwapi $(CFLAGS)

clean:
	@if exist build. del /S /Q build >NUL
	@if exist build. rmdir /S /Q build >NUL
	@if exist *.dll. del *.dll >NUL
	@if exist *.exe. del *.exe >NUL

.PHONY: all clean debug release localization